#' @title A helper function that takes a modelbuilder UI and extracts the model settings
#'
#' @description This function takes a modelbuilder input structure as generated by
#' other functions in that package and extracts UI inputs and saves in a model structure
#' This is a helper function.
#' @param input Shiny UI containing model settings
#' @param mbmodel a modelbuilder model structure
#' @return modelsettings a list containg variables for model settings
#' @details Returned list has vectors var par an time for the model setting.
#' Also returned are UI inputs modeltype, rngseed, nreps, plotscae
#' @author Andreas Handel
#' @export
find_modelsettings <- function(input, mbmodel)
{
modelsettings = list()
modelsettings$modeltype = isolate(input$modeltype)
modelsettings$rngseed = isolate(input$rngseed)
modelsettings$nreps = isolate(input$nreps)
modelsettings$plotscale = isolate(input$plotscale)
#browser()
#process all variables, parameters and times from the inputs
#to create the input string for the main function call
nvars = length(mbmodel$var)
vars=rep(0,nvars)
for (n in 1:nvars)
{
vars[n] = isolate(input[[mbmodel$var[[n]]$varname]])
}
modelsettings$var = vars
npars = length(mbmodel$par)
pars=rep(0,npars)
for (n in 1:npars)
{
pars[n] = isolate(input[[mbmodel$par[[n]]$parname]])
}
modelsettings$par = pars
ntime = length(mbmodel$time)
times = rep(0,ntime)
for (n in 1:ntime)
{
times[n] = isolate(input[[mbmodel$time[[n]]$timename]])
}
modelsettings$time = times
return(modelsettings)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.